<!DOCTYPE html>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <link href="https://cdn.bootcss.com/mapbox-gl/0.38.0/mapbox-gl.css" rel="stylesheet">
    <title>北京村庄分布图</title>
    <style>
        body {
            margin: 0;
            padding: 0;
        }

        #map {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
        }
    </style>
    <script src="http://mapv.baidu.com/build/mapv.min.js"></script>
    <script src="https://cdn.bootcss.com/mapbox-gl/0.38.0/mapbox-gl.js"></script>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script defer="defer" type="text/javascript" src="../../dist/iclient9-mapboxgl.min.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%">
<div id="map"></div>
<script type="text/javascript">
    var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a> with " +
            "<a href='http://mapv.baidu.com/' target='_blank'>© 2017 百度 MapV</a> with <a href='http://iclient.supermapol.com'>© SuperMap iClient</a>";
    var token = "pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw";
    var map = new mapboxgl.Map({
        container: 'map',
        style: {
            "version": 8,
            "sources": {
                "raster-tiles": {
                    "attribution": attribution,
                    "type": "raster",
                    "tiles": ["https://api.tiles.mapbox.com/v4/mapbox.dark/{z}/{x}/{y}.png?access_token=" + token],
                    "tileSize": 256,
                },
            },
            "layers": [{
                "id": "simple-tiles",
                "type": "raster",
                "source": "raster-tiles",
                "minzoom": 0,
                "maxzoom": 22
            }]
        },
        center: [116.443571, 39.887549],
        zoom: 11
    });
    map.addControl(new mapboxgl.NavigationControl(), 'top-left');
    new mapboxgl.Popup({closeOnClick: false})
            .setLngLat(map.getCenter())
            .setHTML('示例数据来源为百度MapV的加偏数据，iClient9未做纠偏处理')
            .addTo(map);

    map.on('load', function () {
        $.get('../data/beijing-village.json', function (data) {

            var dataSet = new mapv.DataSet(data);

            var options = {
                fillStyle: 'rgba(255, 80, 53, 0.8)',
                strokeStyle: 'rgba(250, 255, 53, 0.8)',
                size: 3,
                lineWidth: 1,
                draw: 'simple'
            };
            new mapboxgl.supermap.MapvLayer(map, dataSet, options);
        });
    });
</script>
</body>
</html>
